package org.iteam.xlz.core.service.terminal;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.iteam.db.BaseService;
import org.iteam.xlz.core.entity.terminal.LogProductTerminal;

public class RecordService extends BaseService<LogProductTerminal>{
	private static RecordService instance;
	
	private RecordService(){}
	
	public static RecordService getInstance(){
		if(null==instance){
			instance=new RecordService();
		}
		return instance;
	}
	
	public long counts(){
		try {
			return super.counts("select count(1) from rechargerecord where 1=1 ");
		} catch (SQLException e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	public List<LogProductTerminal> query(long page,long rows){
		try {
			return super.query("select l.logid,l.logtype,r.serialno as tid,p.productname as pid,l.createtime,l.creator,"+
			"l.productamount from logproductterminal l left join terminal r on l.tid=r.tid left join product p "
			+ "on l.pid=p.pid where 1=1 limit ?,?",(page-1)*rows,rows);
		} catch (SQLException e) {
			e.printStackTrace();
			return new ArrayList<LogProductTerminal>();
		}
	}
}
